package com.platform.core.entity;

import com.platform.comm.entity.BaseEntity;
import com.platform.core.entity.listener.SysUserEntityListener;
import com.platform.comm.enums.YnEnum;
import com.platform.enums.CommFlagType;
import com.platform.enums.converters.CommFlagTypeConverter;
import lombok.*;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * Description: 用户
 *
 * @author libin Created on 2019/7/15
 **/
@Data
@Entity
@EntityListeners(SysUserEntityListener.class)
@Table(name = "ncloud_sys_user")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SysUser extends BaseEntity implements Serializable {

    private static final long serialVersionUID = -2114137089567983648L;
    /**
     * 用户名
     */
    @Column(name = "user_name", length = 128, nullable = false, unique = true)
    private String username;

    /**
     * 真实姓名
     */
    @Column(name = "user_real_name", length = 150)
    private String realName;
    /**
     * 密码
     */
    @Column(name = "user_password", length = 256, nullable = false)
    private String password;

    /**
     * 密码过期时间，单位：天
     */
    @Column(name = "pwd_limit_days")
    private Integer pwdLimitDays;

    /**
     * 密码修改日期
     */
    @Column(name = "pwd_modify_date")
    private LocalDateTime pwdModifyDate;

    /**
     * 部门ID
     */
    @Column(name = "depart_id", length = 36)
    private String departId;

    /**
     * 状态标志
     */
    @Column(name = "delflag")
    private YnEnum delFlag;

    /**
     * 用户状态
     */
    @Column(name = "user_status", length = 3)
    @Convert(converter = CommFlagTypeConverter.class)
    private CommFlagType status;

    /**
     * 邮箱地址
     */
    @Column(name = "email", length = 64)
    private String email;

    /**
     * 手机号码
     */
    @Column(name = "mobile_phone", length = 30)
    private String mobile;

    /**
     * 工作电话
     */
    @Column(name = "tel_phone", length = 30)
    private String tel;

    /**
     * 排序
     */
    @Column(name = "sort_num")
    private Integer sortNum;

    /**
     * 备注
     */
    @Column(name = "remark", length = 1024)
    private String remark;

    /**
     * 用户编码
     */
    @Column(name = "user_code", length = 128)
    private String userCode;

    /**
     * 所属管理域
     */
    @Column(name = "manage_domain", length = 36)
    private String domain;

    /**
     * 导入任务Id
     */
    @Column(name = "import_id", length = 36)
    private String importId;

    /**
     * 批量导入状态
     */
    @Column(name = "import_check_flag", length = 20)
    private String importCheckFlag;

    /**
     * 批量导入信息
     */
    @Column(name = "check_err_msg", length = 128)
    private String checkErrMsg;

    /**
     * 首次登录系统时间
     */
    @Column(name = "first_login_date", length = 128)
    private LocalDateTime firstLoginDate;

    /**
     * 信息来源
     */
    @Column(name = "info_source", length = 256)
    private String infoSource;

    /**
     * 用户身份证
     */
    @Column(name = "id_code", length = 64)
    private String idCode;

    /**
     * 证件类型
     */
    @Column(name = "id_type", length = 10)
    private String idType;

    /**
     * 同步状态
     */
    @Column(name = "sync_status", length = 3)
    private String syncStatus;
    public SysUser(String id) {
       this.id = id;
    }

    /**
     * 创建时间
     */
    @Getter
    @Setter
    @CreatedDate
    @Column(name = "create_date", nullable = false, updatable = false)
    private LocalDateTime createDate;


    /**
     * 修改时间
     */
    @Getter
    @Setter
    @LastModifiedDate
    @Column(name = "update_date")
    private LocalDateTime updateDate;

    @Id
    @Column(name = "id", length = 36)
    @Getter
    @Setter
    private String id;

    /**
     * 用户类型
     */
    @Column(name = "user_type", length = 10)
    private String userType;


    /**
     * 头像文件id
     */
    @Column(name = "avatar_file_id", length = 10)
    private String avatarFileId;

}
